package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.mystery;

import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;

public class EmergencyTreatmentSkill extends BaseSkill {

    public EmergencyTreatmentSkill(int level){super(level);}

    public EmergencyTreatmentSkill(NbtCompound nbtCompound){super(nbtCompound);}

    public EmergencyTreatmentSkill(){
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setCooldown(200);
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        return "当低于一定生命值时瞬间进行一次大量治疗";
    }

    public SkillRarity getSkillRarity(){return SkillRarity.Mystery;}

    @Override
    public boolean canUseAbility(MobEntity mobEntity) {
        return mobEntity.world.getTime()>getSkilltime();
    }

    @Override
    public boolean passiveApply(MobEntity mobEntity) {
        if(mobEntity.getHealth()<=mobEntity.getMaxHealth()*0.2)
        {
            if(canUseAbility(mobEntity))
            {
                mobEntity.heal(mobEntity.getMaxHealth()*0.5F+mobEntity.getMaxHealth()*0.1F*getSkillLevel());
                setSkilltime(mobEntity.world.getTime()-getSkillLevel()+getCooldown());
            }
        }
        return true;
    }
}
